<?php if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * @description COURSE MODEL
 */
class subjects_model extends Model {
    
    private $keyword = NULL;

    /**
     * @desc Constructor
     */
    function __construct() {
        // Call the Model constructor
        parent::__construct();
    }

    /**
     * @desc Insert Course
     * @param <array> $arrData
     * @return <bool> true else failed or NULL
     */
    public function insert($arrData) {
        $arrDefault = array(            
            SUBJECTS_NAME => NULL,
            SUBJECTS_PROVIDER_ID => NULL,
        );

        $arrInput = array_merge($arrDefault, $arrData);
        try {
            $this->db->insert(SUBJECTS, $arrInput);
            $subject_id = $this->db->insert_id();
        }
        catch (Exception $e) {
            print_r($e);
            
        }
        
        return $subject_id;
    }

    /**
     * @desc Get Course BY ID
     * @param <type> $arrData
     * @return <type>
     */
    function getSubjectByProviderId($arrData) {
        try {
            $arrCond = array(
                SUBJECTS_PROVIDER_ID => $arrData['provider_id'],
            );
            $this->db->where($arrCond);
            $result = $this->db->get(SUBJECTS)->row();
        }
        catch (Exception $e) {
            print_r($e);
        }
        return $result;
    }
    
}

?>